﻿using System;
using System.Data;
using System.Linq;
using ReflectionStudio.Core.Events;
namespace WPFExcelReport
{
    public partial class ITXEXRPT
    {

        private void YGRQCYM(DataSet db)
        {
            try
            {/*<GPGART,GPGVAR,GPGFARBE,GPSPPART,GPFBPART,GPZWPART,GABLO,GABLB,GABBUCHDAT,INQTY,PRODIN ,OUTQTY, ADJQTY--> */
                DataTable dtSoruce = db.Tables["GPDAT"];
                DataTable dtOutput = new DataTable();
                int idx = 1;
                exAgent.SetCellValue(3, idx++, "批号"); dtOutput.Columns.Add("GPSPPART", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "质检单号"); dtOutput.Columns.Add("QOKORDER", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "品种"); dtOutput.Columns.Add("GPGART", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "色号"); dtOutput.Columns.Add("GPGFARBE", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "回潮率"); dtOutput.Columns.Add("Y001", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "含杂率"); dtOutput.Columns.Add("Y002", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "马克隆值"); dtOutput.Columns.Add("Y003", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "断裂比强度（cN/tex）"); dtOutput.Columns.Add("Y004", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "上半部平均长度(mm)"); dtOutput.Columns.Add("Y005", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "整齐度指数"); dtOutput.Columns.Add("Y006", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "短纤指数（%）"); dtOutput.Columns.Add("Y007", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "纺纱一致性参数"); dtOutput.Columns.Add("Y008", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "棉结（粒/g）"); dtOutput.Columns.Add("Y009", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "备注"); dtOutput.Columns.Add("Y010", typeof(System.String)); 
                dtOutput.Merge(dtSoruce, false, MissingSchemaAction.Ignore);
                foreach (DataRow row in dtOutput.Rows)
                {
                    row["GPSPPART"] = GetGB2312Value(row["GPSPPART"].ToString());
                    row["GPGFARBE"] = GetGB2312Value(row["GPGFARBE"].ToString());
                    row["Y010"] = GetGB2312Value(row["Y010"].ToString());
                }
                exAgent.DataTableToExcel(dtOutput, 4, 1); 
                int count = dtOutput.Rows.Count;
                exAgent.SetCellValue(1, 1, 1); 
                exAgent.BatchConvert2Number(4, 5, count + 3, 13);
                exAgent.SetCellValue(1, 1, "原棉质量");

            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        
    }
}